# -*- coding: utf-8 -*-
# @Create_time   : 2023-11-05 16:00:00 UTC
# @Author        :kumiler
# @emial         :lukunming@jtexpress.com
# @File          :__init__.py
# @Desc          :

from datetime import timedelta
from utils.operators.cluster_for_spark_sql_hook_test_for_airflow_bug_operator import SparkSqlOperator


spmi_dwd__dwd_spmi_operation_bill_base_dt = SparkSqlOperator(
    task_id='spmi_dwd__dwd_spmi_operation_bill_base_dt',
    email=['lukunmingn@jtexpress.com','yl_bigdata@yl-scm.com'],
    master='yarn',
    name='spmi_dwd__dwd_spmi_operation_bill_base_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms_route_test/dm/dwd_spmi_operation_bill_base_dt/execute.sql',
    pool_slots=2,
    driver_cores=2,
    driver_memory='4G',
    executor_cores=6,
    executor_memory='12G',
    num_executors=90,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
          'spark.dynamicAllocation.maxExecutors'             : 92,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 300,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
          'spark.executor.memoryOverhead'                    : '4G',
          'spark.yarn.maxAppAttempts'                        : 1,
          'spark.sql.shuffle.partitions': 2000,
          'spark.shuffle.memoryFraction': '1.0',
          'spark.shuffle.file.buffer':'64K',
          #'spark.shuffle.consolidateFiles':'true',
          #'spark.storage.memoryFraction': '0.8',
          'spark.reducer.maxSizeInFlight':'96m',
          'spark.executor.extraJavaOptions': '-XX:+UseG1GC -XX:ParallelGCThreads=6 -XX:ConcGCThreads=2'
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 300,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 300,  # 最大分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=100),
    retries=0,
)


